home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / c / Vperf5.1-src.lha / Viewperf5.1 / viewperf / EnvAOS.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-09-19  |  32.7 KB  |  1,058 lines

  1. #include <stdio.h>
  2. #include <ctype.h>
  3. #include <string.h>
  4. #include <errno.h>
  5. #include <time.h>
  6. #include <math.h>
  7. #include "Env.h"
  8. #include <malloc.h>
  9. #include <gl/glaux.h>
  10. #include "viewperf.h"
  11.  
  12. static char *GetShortVendorName(char *input);
  13. static int GetHostMemorySize(void);
  14. static char *GetHostVendor(void);
  15. static char *GetHostModel(void);
  16. static char *GetHostCPU(void);
  17. static char *GetHostOperatingSystem(void);
  18. static char *GetHostOperatingSystemRelease(void);
  19. static char *GetHostName(void);
  20. static char *GetOpenGLClientVendor(void);
  21. static char *GetOpenGLClientVersion(void);
  22. static char *GetOpenGLClientExtensions(void);
  23. static char *GetHostCPUCount(void);
  24. static char *GetHostPrimaryCacheSize(void);
  25. static char *GetHostSecondaryCacheSize(void);
  26. static char *GetWindowSystem(void);
  27. static char *GetDriverVersion(void);
  28.  
  29.  
  30. /******************************************************************************
  31.  *
  32.  * StringSearch - search for pattern in string
  33.  *
  34.  * Description:
  35.  *  StringSearch returns a pointer to the first occurance of pattern found in
  36.  *  the subject or NULL if the pattern is not found. It implements the
  37.  *  Knuth-Morris-Pratt pattern matching algorithm. If m is the length of the
  38.  *  pattern and n is the length of the subject, the complexity of the KMP
  39.  *  algorithm is (m+n), much better than the (m*n) complexity of the naive
  40.  *  nested loop algorithm. - John Dennis
  41.  *
  42.  * Returns:
  43.  *  pointer to the first occurance of pattern found the subject or NULL
  44.  *
  45.  * Side Effects:
  46.  *  None
  47.  *
  48.  * Errors:
  49.  *  None
  50.  *
  51.  * Revision History:
  52.  *  Revision 0: Author: John R. Dennis Date: Thu Aug  4 15:49:59 1994
  53.  *    Initial Release
  54.  *
  55.  *****************************************************************************/
  56. char *
  57. StringSearch(char *subject, char *pattern)
  58. {
  59. #define MAX_FLINK (256)
  60.   int *flink, *dynamicFlink = NULL, staticFlink[MAX_FLINK];
  61.   int patternLen = strlen(pattern);
  62.   int subjectLen = strlen(subject);
  63.   int found = 0;
  64.   int i,j;
  65.  
  66.   if (patternLen > MAX_FLINK) {      /* -1 for NULL terminator */
  67.     dynamicFlink = malloc(patternLen * sizeof(int));
  68.     if (dynamicFlink == NULL) {
  69.       fprintf(stderr, "malloc failure, line %d, file: %s, exiting...\n",
  70.           __LINE__, __FILE__);
  71.       exit(1);
  72.     }
  73.     flink = dynamicFlink;
  74.   }
  75.   else {
  76.     flink = staticFlink;
  77.   }
  78.  
  79.  
  80.   /* Step 1: Constuct Flowchart */
  81.   flink[0] = -1;               /* -1 == read next char */
  82.   for(i = 1; i < patternLen; i++) {
  83.     j = flink[i-1];
  84.     while((j >= 0) && (pattern[j] != pattern[i-1])) {
  85.       j = flink[j];
  86.     }
  87.     flink[i] = j+1;
  88.   }
  89.  
  90.   /* Step 2: Scan Algorithm */
  91.   for (i = j = 0; i < subjectLen; i++, j++) {
  92.     while((j >= 0) && (pattern[j] != subject[i])) {
  93.       j = flink[j];
  94.     }
  95.     if (j == patternLen-1) {
  96.       found = 1;
  97.       goto exit;
  98.     }
  99.   }
  100.  
  101.  exit:
  102.   if (dynamicFlink != NULL) free(dynamicFlink);
  103.   if (!found)
  104.     return(NULL);
  105.   else
  106.     return(&subject[i-patternLen+1]);
  107. #undef MAX_FLINK
  108. }
  109.  
  110.  
  111. /******************************************************************************
  112.  *
  113.  * GetShortVendorName - return short vendor string
  114.  *
  115.  * Description:
  116.  *  some vendor strings are verbose. This function will return a shortest
  117.  *  vendor name it can given an arbitrary vendor string. The returned string
  118.  *  is allocated with malloc, it should be freed when no longer in use. The
  119.  *  input string is not freed or modified by this function.
  120.  *
  121.  * Returns:
  122.  *  pointer to allocated string
  123.  *
  124.  * Side Effects:
  125.  *  string allocation, string should be freed when no longer needed.
  126.  *
  127.  * Errors:
  128.  *  no errors, if function fails the string "unknown" is returned
  129.  *
  130.  * Revision History:
  131.  *  Revision 0: Author: John R. Dennis Date: Mon Aug  8 16:30:53 1994
  132.  *    Initial Release
  133.  *
  134.  *****************************************************************************/
  135. static char *
  136. GetShortVendorName(char *input)
  137. {
  138.   int i;
  139.   char *s1 = NULL;              /* s1 is temp work string */
  140.   char *s2 = NULL;              /* s2 is string to return */
  141.  
  142.   /* duplicate input string so that we can modify it */
  143.   s1 = strdup(input);
  144.   /* upcase string */
  145.   for (i = 0; s1[i]; i++)
  146.     if (islower(s1[i])) s1[i] = toupper(s1[i]);
  147.  
  148.   /* return a short name if possible, some vendor names are verbose */
  149.   if (StringSearch(s1, "DEC") ||
  150.       StringSearch(s1, "DECWINDOWS") ||
  151.       StringSearch(s1, "Digital Equipment Corporation") ||
  152.       StringSearch(s1, "DigitalEquipmentCorporation"))
  153.     s2 = strdup("DEC");
  154.   else if (StringSearch(s1, "SGI") ||
  155.        StringSearch(s1, "SILCON GRAPHICS"))
  156.     s2 = strdup("SGI");
  157.   else if (StringSearch(s1, "IBM") ||
  158.        StringSearch(s1, "INTERNATIONAL BUSINESS MACHINES"))
  159.     s2 = strdup("IBM");
  160.   else
  161.     s2 = strdup(s1);
  162.  
  163.   free(s1);
  164.   return(s2);
  165. }
  166.  
  167.  
  168. /******************************************************************************
  169.  *
  170.  * GetHostMemorySize - Return kilobytes of memory installed on host platform
  171.  *
  172.  * Description:
  173.  *  Returns the number of kilobytes of memory installed on host platform
  174.  *
  175.  * Returns:
  176.  *  kilobytes of host platform memory
  177.  *
  178.  * Side Effects:
  179.  *  None
  180.  *
  181.  * Errors:
  182.  *  return 0 if unable to determine memory configuration
  183.  *
  184.  * Revision History:
  185.  *  Revision 0: Author: John R. Dennis Date: Thu Aug  4 15:55:19 1994
  186.  *    Initial Release
  187.  *
  188.  *****************************************************************************/
  189. static int
  190. GetHostMemorySize(void)
  191. {
  192.   /* AvailMem */
  193.   return (24 * 1024 * 1024) / 1024;
  194. }
  195.  
  196.  
  197. /******************************************************************************
  198.  *
  199.  * GetHostVendor - return string naming the system vendor
  200.  *
  201.  * Description:
  202.  *  return the name of the system vendor as a string. This is to identify
  203.  *  manufacturer of the system. The string is allocated with malloc, it should
  204.  *  be freed when no longer in use.
  205.  *
  206.  * Returns:
  207.  *  pointer to allocated string
  208.  *
  209.  * Side Effects:
  210.  *  string allocation, string should be freed when no longer needed.
  211.  *
  212.  * Errors:
  213.  *  no errors, if function fails the string "unknown" is returned
  214.  *
  215.  * Revision History:
  216.  *  Revision 0: Author: John R. Dennis Date: Mon Aug  8 16:30:53 1994
  217.  *    Initial Release
  218.  *
  219.  *****************************************************************************/
  220. static char *
  221. GetHostVendor(void)
  222. {
  223.   /* See if it's a DEC system */
  224.   char *hostModel;
  225.  
  226.   hostModel = GetHostModel();
  227.   if ( strstr(hostModel,"DEC") == hostModel)
  228.   {
  229.     free(hostModel);
  230.     return(strdup("DEC"));
  231.   }
  232.   else
  233.   {
  234.     free(hostModel);
  235.     return(strdup("unknown"));
  236.   }
  237. }
  238.  
  239.  
  240. /******************************************************************************
  241.  *
  242.  * GetHostModel - return string naming the host model
  243.  *
  244.  * Description:
  245.  * return string identifying the host platform's model designation. The string
  246.  * is allocated with malloc, it should be freed when no longer in use.
  247.  *
  248.  * Returns:
  249.  *  pointer to allocated string
  250.  *
  251.  * Side Effects:
  252.  *  string allocation, string should be freed when no longer needed.
  253.  *
  254.  * Errors:
  255.  *  no errors, if function fails the string "unknown" is returned
  256.  *
  257.  * Revision History:
  258.  *  Revision 0: Author: John R. Dennis Date: Mon Aug  8 16:30:53 1994
  259.  *    Initial Release
  260.  *
  261.  *****************************************************************************/
  262. static char *
  263. GetHostModel(void)
  264. {
  265.   return strdup("AmigaOS");
  266. }
  267.  
  268.  
  269. /******************************************************************************
  270.  *
  271.  * GetHostCPU - return string naming the host CPU
  272.  *
  273.  * Description:
  274.  * return string identifying the host platform's CPU. The string
  275.  * is allocated with malloc, it should be freed when no longer in use.
  276.  *
  277.  * Returns:
  278.  *  pointer to allocated string
  279.  *
  280.  * Side Effects:
  281.  *  string allocation, string should be freed when no longer needed.
  282.  *
  283.  * Errors:
  284.  *  no errors, if function fails the string "unknown" is returned
  285.  *
  286.  * Revision History:
  287.  *  Revision 0: Author: John R. Dennis Date: Mon Aug  8 16:30:53 1994
  288.  *    Initial Release
  289.  *
  290.  *****************************************************************************/
  291. static char *
  292. GetHostCPU(void)
  293. {
  294.   return strdup("Motorola MC68030 (30MHz), MC68882 (30MHz)");
  295. }
  296.  
  297.  
  298. /******************************************************************************
  299.  *
  300.  * GetHostCPUCount - return string indicating number of host CPU's
  301.  *
  302.  * Description:
  303.  * return string indicating number of host CPU's. The string "unknown" is
  304.  * returned if the count is not determinable. The string is allocated with
  305.  * malloc, it should be freed when no longer in use.
  306.  *
  307.  * Returns:
  308.  *  pointer to allocated string
  309.  *
  310.  * Side Effects:
  311.  *  string allocation, string should be freed when no longer needed.
  312.  *
  313.  * Errors:
  314.  *  no errors, if function fails the string "unknown" is returned
  315.  *
  316.  * Revision History:
  317.  *  Revision 0: Author: John R. Dennis Date: Mon Feb 27 14:18:41 EST 1995
  318.  *    Initial Release
  319.  *
  320.  *****************************************************************************/
  321. static char *
  322. GetHostCPUCount(void)
  323. {
  324.   return(strdup("unknown"));
  325. }
  326.  
  327. /******************************************************************************
  328.  *
  329.  * GetHostPrimaryCacheSize - return string indicating host's primary cache (KB)
  330.  *
  331.  * Description:
  332.  * return string indicating the number of kilobytes of primary cache on the
  333.  * host's CPU, or "unknown" if not determinable. The string
  334.  * is allocated with malloc, it should be freed when no longer in use.
  335.  *
  336.  * Returns:
  337.  *  pointer to allocated string
  338.  *
  339.  * Side Effects:
  340.  *  string allocation, string should be freed when no longer needed.
  341.  *
  342.  * Errors:
  343.  *  no errors, if function fails the string "unknown" is returned
  344.  *
  345.  * Revision History:
  346.  *  Revision 0: Author: John R. Dennis Date: Mon Feb 27 14:18:41 EST 1995
  347.  *    Initial Release
  348.  *
  349.  *****************************************************************************/
  350. static char *
  351. GetHostPrimaryCacheSize(void)
  352. {
  353.   return(strdup("0 KB"));
  354. }
  355.  
  356. /******************************************************************************
  357.  *
  358.  * GetHostSecondaryCacheSize - return string indicating host's secondary cache (KB)
  359.  *
  360.  * Description:
  361.  * return string indicating the number of kilobytes of secondary cache on the
  362.  * host's CPU, or "unknown" if not determinable. The string
  363.  * is allocated with malloc, it should be freed when no longer in use.
  364.  *
  365.  * Returns:
  366.  *  pointer to allocated string
  367.  *
  368.  * Side Effects:
  369.  *  string allocation, string should be freed when no longer needed.
  370.  *
  371.  * Errors:
  372.  *  no errors, if function fails the string "unknown" is returned
  373.  *
  374.  * Revision History:
  375.  *  Revision 0: Author: John R. Dennis Date: Mon Feb 27 14:18:41 EST 1995
  376.  *    Initial Release
  377.  *
  378.  *****************************************************************************/
  379. static char *
  380. GetHostSecondaryCacheSize(void)
  381. {
  382.   return(strdup("0 KB"));
  383. }
  384.  
  385. /******************************************************************************
  386.  *
  387.  * GetWindowSystem - return string naming the windowing system
  388.  *
  389.  * Description:
  390.  * return string identifying the windowing system in use on the target
  391.  * device. The string is allocated with malloc, it should be freed when no
  392.  * longer in use.
  393.  *
  394.  * Returns:
  395.  *  pointer to allocated string
  396.  *
  397.  * Side Effects:
  398.  *  string allocation, string should be freed when no longer needed.
  399.  *
  400.  * Errors:
  401.  *  no errors, if function fails the string "unknown" is returned
  402.  *
  403.  * Revision History:
  404.  *  Revision 0: Author: John R. Dennis Date: Mon Aug  8 16:30:53 1994
  405.  *    Initial Release
  406.  *
  407.  *****************************************************************************/
  408. static char *
  409. GetWindowSystem(void)
  410. {
  411.   return(strdup("MesaGL"));
  412. }
  413.  
  414. /******************************************************************************
  415.  *
  416.  * GetDriverVersion - return string identifying the graphics driver
  417.  *
  418.  * Description:
  419.  * Return string identifying the graphics driver version. If there is no
  420.  * graphics driver than the string "NA" is returned. If a graphics driver
  421.  * exists, but the function cannot identify it then the string "unknown" is
  422.  * returned.  The string is allocated with malloc, it should be freed when no
  423.  * longer in use.
  424.  *
  425.  * Returns:
  426.  *  pointer to allocated string
  427.  *
  428.  * Side Effects:
  429.  *  string allocation, string should be freed when no longer needed.
  430.  *
  431.  * Errors:
  432.  *  no errors, if function fails the string "unknown" is returned
  433.  *
  434.  * Revision History:
  435.  *  Revision 0: Author: John R. Dennis Date: Mon Feb 27 15:00:18 EST 1995
  436.  *    Initial Release
  437.  *
  438.  *****************************************************************************/
  439. static char *
  440. GetDriverVersion(void)
  441. {
  442.   return(strdup("3.0"));
  443. }
  444.  
  445. /******************************************************************************
  446.  *
  447.  * GetHostOperatingSystem - return string naming the host CPU operating system
  448.  *
  449.  * Description:
  450.  *  return the type of the host operating system as a string. This is to
  451.  *  identify what type of operating system this program is running under. The
  452.  *  string is allocated with malloc, it should be freed when no longer in use.
  453.  *
  454.  * Returns:
  455.  *  pointer to allocated string
  456.  *
  457.  * Side Effects:
  458.  *  string allocation, string should be freed when no longer needed.
  459.  *
  460.  * Errors:
  461.  *  no errors, if function fails the string "unknown" is returned
  462.  *
  463.  * Revision History:
  464.  *  Revision 0: Author: John R. Dennis Date: Mon Aug  8 16:30:53 1994
  465.  *    Initial Release
  466.  *
  467.  *****************************************************************************/
  468. static char *
  469. GetHostOperatingSystem(void)
  470. {
  471.   return(strdup("AmigaOS 3.1"));
  472. }
  473.  
  474.  
  475. /******************************************************************************
  476.  *
  477.  * GetHostOperatingSystemRelease - return string naming operating system release
  478.  *
  479.  * Description:
  480.  *  return the release/version of the host operating system as a string. This
  481.  *  is to identify what version of the operating system this program is
  482.  *  running under. The string is allocated with malloc, it should be freed
  483.  *  when no longer in use.
  484.  *
  485.  * Returns:
  486.  *  pointer to allocated string
  487.  *
  488.  * Side Effects:
  489.  *  string allocation, string should be freed when no longer needed.
  490.  *
  491.  * Errors:
  492.  *  no errors, if function fails the string "unknown" is returned
  493.  *
  494.  * Revision History:
  495.  *  Revision 0: Author: John R. Dennis Date: Mon Aug  8 16:30:53 1994
  496.  *    Initial Release
  497.  *
  498.  *****************************************************************************/
  499. static char *
  500. GetHostOperatingSystemRelease(void)
  501. {
  502.   return(strdup("40.72"));
  503. }
  504.  
  505.  
  506. /******************************************************************************
  507.  *
  508.  * GetHostName - return string naming the host
  509.  *
  510.  * Description:
  511.  *  return the name of this host as a string. This is to identify which
  512.  *  platform this program is running on. The string is allocated with malloc,
  513.  *  it should be freed when no longer in use.
  514.  *
  515.  * Returns:
  516.  *  pointer to allocated string
  517.  *
  518.  * Side Effects:
  519.  *  string allocation, string should be freed when no longer needed.
  520.  *
  521.  * Errors:
  522.  *  no errors, if function fails the string "unknown" is returned
  523.  *
  524.  * Revision History:
  525.  *  Revision 0: Author: John R. Dennis Date: Mon Aug  8 16:30:53 1994
  526.  *    Initial Release
  527.  *
  528.  *****************************************************************************/
  529. static char *
  530. GetHostName(void)
  531. {
  532.   return(strdup("RamsesIII"));
  533. }
  534.  
  535.  
  536. /******************************************************************************
  537.  *
  538.  * GetDateTime - get the current month, day, year, hour, minute
  539.  *
  540.  * Description:
  541.  *  Get the current  day, month, year, hour, minute. Each is a pointer to an
  542.  *  integer. If the pointer is NULL then no value is returned for that
  543.  *  parameter, otherwise an assignment is made to the integer pointed to by
  544.  *  the parameter.
  545.  *
  546.  *  month:  in the range [1-12] 1=January, 12=December
  547.  *  day:    in the range [1-31]
  548.  *  year:   as a 4 digit number, e.g. 1994
  549.  *  hour:   in the range [0-23]
  550.  *  min:    in the range [0-59]
  551.  *
  552.  * Returns:
  553.  *  0 for success, error code otherwise
  554.  *
  555.  * Side Effects:
  556.  *  None
  557.  *
  558.  * Errors:
  559.  *  return non-zero on failure
  560.  *
  561.  * Revision History:
  562.  *  Revision 0: Author: John R. Dennis Date: Wed Aug 17 13:08:36 1994
  563.  *    Initial Release
  564.  *
  565.  *****************************************************************************/
  566.  
  567. int
  568. GetDateTime(int *month, int *day, int *year, int *hour, int *minute)
  569. {
  570.   time_t timeT;
  571.   struct tm *timeTm;
  572.  
  573.   time(&timeT);
  574.   timeTm = localtime(&timeT);
  575.   if (timeTm == NULL) {
  576.     fprintf(stderr, "Error calling localtime: %d\n", errno);
  577.     return(errno);
  578.   }
  579.   if (month)  *month  = timeTm->tm_mon + 1;
  580.   if (day)    *day    = timeTm->tm_mday;
  581.   if (year)   *year   = timeTm->tm_year + 1900;
  582.   if (hour)   *hour   = timeTm->tm_hour;
  583.   if (minute) *minute = timeTm->tm_min;
  584.   return(0);
  585. }
  586.  
  587.  
  588. /******************************************************************************
  589.  *
  590.  * GetOpenGLClientVendor - return string naming the client library vendor
  591.  *
  592.  * Description:
  593.  *  return the name of the vendor supplying the OpenGL client library.  The
  594.  *  string is allocated with malloc,it should be freed when no longer in use.
  595.  *
  596.  * Returns:
  597.  *  pointer to allocated string
  598.  *
  599.  * Side Effects:
  600.  *  string allocation, string should be freed when no longer needed.
  601.  *
  602.  * Errors:
  603.  *  no errors, if function fails the string "unknown" is returned
  604.  *
  605.  * Revision History:
  606.  *  Revision 0: Author: John R. Dennis Date: Mon Aug  8 16:30:53 1994
  607.  *    Initial Release
  608.  *
  609.  *****************************************************************************/
  610. static char *
  611. GetOpenGLClientVendor(void)
  612. {
  613.   char *pstr;
  614.   if (pstr = (char *)glGetString(GL_VENDOR))
  615.     return(GetShortVendorName(pstr));
  616.   else
  617.     return(strdup("unknown"));
  618. }
  619.  
  620.  
  621. /******************************************************************************
  622.  *
  623.  * GetOpenGLClientVersion - return string naming the client library version
  624.  *
  625.  * Description:
  626.  *  return the version of the OpenGL client library.  The string is allocated
  627.  *  with malloc,it should be freed when no longer in use.
  628.  *
  629.  * Returns:
  630.  *  pointer to allocated string
  631.  *
  632.  * Side Effects:
  633.  *  string allocation, string should be freed when no longer needed.
  634.  *
  635.  * Errors:
  636.  *  no errors, if function fails the string "unknown" is returned
  637.  *
  638.  * Revision History:
  639.  *  Revision 0: Author: John R. Dennis Date: Mon Aug  8 16:30:53 1994
  640.  *    Initial Release
  641.  *
  642.  *****************************************************************************/
  643. static char *
  644. GetOpenGLClientVersion(void)
  645. {
  646.   char *pstr;
  647.   if (pstr = (char *)glGetString(GL_VERSION))
  648.     return(strdup(pstr));
  649.   else
  650.     return(strdup("unknown"));
  651. }
  652.  
  653.  
  654. /******************************************************************************
  655.  *
  656.  * GetOpenGLClientExtensions - return string naming the client extensions
  657.  *
  658.  * Description:
  659.  *  return the extensions supported in the OpenGL client library.  The string
  660.  *  is allocated with malloc,it should be freed when no longer in use.
  661.  *
  662.  * Returns:
  663.  *  pointer to allocated string
  664.  *
  665.  * Side Effects:
  666.  *  string allocation, string should be freed when no longer needed.
  667.  *
  668.  * Errors:
  669.  *  no errors, if function fails the string "unknown" is returned
  670.  *
  671.  * Revision History:
  672.  *  Revision 0: Author: John R. Dennis Date: Mon Aug  8 16:30:53 1994
  673.  *    Initial Release
  674.  *
  675.  *****************************************************************************/
  676. static char *
  677. GetOpenGLClientExtensions(void)
  678. {
  679.   char *pstr;
  680.   if (pstr = (char *)glGetString(GL_EXTENSIONS))
  681.     return(strdup(pstr));
  682.   else
  683.     return(strdup("unknown"));
  684. }
  685.  
  686.  
  687.  
  688. /******************************************************************************
  689.  *
  690.  * GetEnvironment - return info about environment test was run in
  691.  *
  692.  * Description:
  693.  *  This function fills in an environment info record with every pertinent
  694.  *  piece of information about the condiditons under which the test was run.
  695.  *
  696.  * Returns:
  697.  *  0 success, error code otherwise
  698.  *
  699.  * Side Effects:
  700.  *  None
  701.  *
  702.  * Errors:
  703.  *  errors generally only with bad configurations, too many to list
  704.  *
  705.  * Revision History:
  706.  *  Revision 0: Author: John R. Dennis Date: Thu Aug 18 16:52:35 1994
  707.  *    Initial Release
  708.  *
  709.  *****************************************************************************/
  710.  
  711. #include <intuition/intuition.h>
  712. #include <intuition/screens.h>
  713. #include <gl/amigamesa.h>
  714.  
  715. void
  716. GetAOSEnvironment(EnvironmentInfo *info) {
  717.   struct amigamesa_context *amesa;
  718.   
  719.   if(!(amesa = auxAOSContext()))
  720.     return;
  721.   
  722.   info->windowWidth = amesa->window->GZZWidth;
  723.   info->windowHeight = amesa->window->GZZHeight;
  724.   info->screenWidth = amesa->Screen->Width;
  725.   info->screenHeight = amesa->Screen->Height;
  726.   
  727.   info->bufConfig.doubleBuffer = amesa->visual->db_flag;
  728.   info->bufConfig.stereo = -1;
  729.   if(!(info->bufConfig.rgba = amesa->visual->rgb_flag)) {
  730.     info->bufConfig.indexSize = amesa->visual->depth;
  731.  
  732.     info->bufConfig.redSize = -1;
  733.     info->bufConfig.greenSize = -1;
  734.     info->bufConfig.blueSize = -1;
  735.     info->bufConfig.alphaSize = -1;
  736.     info->bufConfig.accumRedSize = -1;
  737.     info->bufConfig.accumGreenSize = -1;
  738.     info->bufConfig.accumBlueSize = -1;
  739.     info->bufConfig.accumAlphaSize = -1;
  740.   }
  741.   else {
  742.     info->bufConfig.indexSize = -1;
  743.  
  744.     info->bufConfig.redSize = amesa->visual->gl_visual->RedBits;
  745.     info->bufConfig.greenSize = amesa->visual->gl_visual->GreenBits;
  746.     info->bufConfig.blueSize = amesa->visual->gl_visual->BlueBits;
  747.     info->bufConfig.alphaSize = amesa->visual->gl_visual->AlphaBits;
  748.     info->bufConfig.accumRedSize = amesa->visual->gl_visual->AccumBits;
  749.     info->bufConfig.accumGreenSize = amesa->visual->gl_visual->AccumBits;
  750.     info->bufConfig.accumBlueSize = amesa->visual->gl_visual->AccumBits;
  751.     info->bufConfig.accumAlphaSize = amesa->visual->gl_visual->AccumBits;
  752.   }
  753.  
  754.   info->bufConfig.depthSize = amesa->visual->gl_visual->DepthBits;
  755.   info->bufConfig.stencilSize = amesa->visual->gl_visual->StencilBits;
  756.  
  757.   info->bufConfig.auxBuffers = 0;
  758. }
  759.  
  760. int
  761. GetEnvironment(EnvironmentInfo *info)
  762. {
  763.   GLenum windType;
  764.  
  765.   FreeEnvironmentData(info);
  766.  
  767.   GetDateTime(&info->month, &info->day, &info->year, NULL, NULL);
  768.   info->host = GetHostName();
  769.   info->hostOperatingSystem = GetHostOperatingSystem();
  770.   info->hostOperatingSystemVersion = GetHostOperatingSystemRelease();
  771.   info->hostVendor = GetHostVendor();
  772.   info->hostModel = GetHostModel();
  773.   info->hostCPU = GetHostCPU();
  774.   info->hostCPUCount = GetHostCPUCount();
  775.   info->hostPrimaryCacheSize = GetHostPrimaryCacheSize();
  776.   info->hostSecondaryCacheSize = GetHostSecondaryCacheSize();
  777.   info->windowSystem = GetWindowSystem();
  778.   info->driverVersion = GetDriverVersion();
  779.   info->hostMemorySize = GetHostMemorySize() / 1024; /* kilobytes to MB */
  780.   info->glVendor = GetShortVendorName((char *)glGetString(GL_VENDOR));
  781.   info->glVersion = strdup((char *)glGetString(GL_VERSION));
  782.   info->glRenderer = strdup((char *)glGetString(GL_RENDERER));
  783.   info->glExtensions = strdup((char *)glGetString(GL_EXTENSIONS));
  784.   info->glClientVendor = GetOpenGLClientVendor();
  785.   info->glClientVersion = GetOpenGLClientVersion();
  786.   info->glClientExtensions = GetOpenGLClientExtensions();
  787.  
  788. #ifdef GLU_VERSION_1_1
  789.   info->gluVersion = strdup((char *)gluGetString(GLU_VERSION));;
  790.   info->gluExtensions = strdup((char *)gluGetString(GLU_EXTENSIONS));;
  791. #else
  792.   info->gluVersion = strdup("unknown");
  793.   info->gluExtensions = strdup("unknown");
  794. #endif
  795.  
  796.   GetAOSEnvironment(info);
  797.  
  798. #if defined(WIN32)
  799.   /*
  800.    * There is no direct rendering at this time.
  801.    */
  802.   info->directRender = FALSE;
  803. #else
  804.   /*
  805.    * Direct rendering is a "request", not a guarantee. We need to check the
  806.    * direct render bit for each test because the GL context is only set up
  807.    * in the above conditional block. If we didn't check it for each test
  808.    * then the value for direct rendering store in the test descriptor would
  809.    * be the "request" value, not the actual value.
  810.    */
  811.  
  812.   windType = auxGetDisplayMode();
  813.   if (windType & AUX_DIRECT)
  814.     info->directRender = TRUE;
  815.   else
  816.     info->directRender = FALSE;
  817. #endif
  818.  
  819.     return (0);
  820. }
  821.  
  822.  
  823.  
  824. /******************************************************************************
  825.  *
  826.  * FreeEnvironmentData - frees all dynamic data in EnvironmentInfo struct
  827.  *
  828.  * Description:
  829.  *  Free all the dynamically allocated data in an EnvironmentInfo struct. Each
  830.  *  pointer in the struct is assigned the value of NULL after its data has
  831.  *  been freed. The struct itself is not freed.
  832.  *
  833.  * Returns:
  834.  *  void
  835.  *
  836.  * Side Effects:
  837.  *  free dynamically allocated memory
  838.  *
  839.  * Errors:
  840.  *  None
  841.  *
  842.  * Revision History:
  843.  *  Revision 0: Author: John R. Dennis Date: Tue Sep 13 17:31:19 1994
  844.  *    Initial Release
  845.  *
  846.  *****************************************************************************/
  847.  
  848. void
  849. FreeEnvironmentData(EnvironmentInfo *info)
  850. {
  851.   if (info->host != NULL) free(info->host);
  852.   if (info->hostOperatingSystem != NULL) free(info->hostOperatingSystem);
  853.   if (info->hostOperatingSystemVersion != NULL) free(info->hostOperatingSystemVersion);
  854.   if (info->hostVendor != NULL) free(info->hostVendor);
  855.   if (info->hostModel != NULL) free(info->hostModel);
  856.   if (info->hostCPU != NULL) free(info->hostCPU);
  857.   if (info->hostCPUCount != NULL) free(info->hostCPUCount);
  858.   if (info->hostPrimaryCacheSize != NULL) free(info->hostPrimaryCacheSize);
  859.   if (info->hostSecondaryCacheSize != NULL) free(info->hostSecondaryCacheSize);
  860.   if (info->windowSystem != NULL) free(info->windowSystem);
  861.   if (info->driverVersion != NULL) free(info->driverVersion);
  862.   if (info->glVendor != NULL) free(info->glVendor);
  863.   if (info->glVersion != NULL) free(info->glVersion);
  864.   if (info->glRenderer != NULL) free(info->glRenderer);
  865.   if (info->glExtensions != NULL) free(info->glExtensions);
  866.   if (info->glClientVendor != NULL) free(info->glClientVendor);
  867.   if (info->glClientVersion != NULL) free(info->glClientVersion);
  868.   if (info->glClientExtensions != NULL) free(info->glClientExtensions);
  869.   if (info->gluVersion != NULL) free(info->gluVersion);
  870.   if (info->gluExtensions != NULL) free(info->gluExtensions);
  871.   NullEnvironmentData(info);
  872. }
  873.  
  874.  
  875. /******************************************************************************
  876.  *
  877.  * NullEnvironmentData - sets all dynamic data ptrs in EnvironmentInfo to NULL
  878.  *
  879.  * Description:
  880.  *  Sets all the pointers to dynamically allocated data in an EnvironmentInfo
  881.  *  struct to NULL. The data pointed to by the pointers are not freed, use the
  882.  *  function FreeEnvironmentData for that purpose.
  883.  *
  884.  * Returns:
  885.  *  void
  886.  *
  887.  * Side Effects:
  888.  *  None
  889.  *
  890.  * Errors:
  891.  *  None
  892.  *
  893.  * Revision History:
  894.  *  Revision 0: Author: John R. Dennis Date: Tue Sep 13 17:31:19 1994
  895.  *    Initial Release
  896.  *
  897.  *****************************************************************************/
  898.  
  899. void
  900. NullEnvironmentData(EnvironmentInfo *info)
  901. {
  902.     info->host = NULL;
  903.     info->hostOperatingSystem = NULL;
  904.     info->hostOperatingSystemVersion = NULL;
  905.     info->hostVendor = NULL;
  906.     info->hostModel = NULL;
  907.     info->hostCPU = NULL;
  908.     info->hostCPUCount = NULL;
  909.     info->hostPrimaryCacheSize = NULL;
  910.     info->hostSecondaryCacheSize = NULL;
  911.     info->windowSystem = NULL;
  912.     info->driverVersion = NULL;
  913.     info->glVendor = NULL;
  914.     info->glVersion = NULL;
  915.     info->glRenderer = NULL;
  916.     info->glExtensions = NULL;
  917.     info->glClientVendor = NULL;
  918.     info->glClientVersion = NULL;
  919.     info->glClientExtensions = NULL;
  920.     info->gluVersion = NULL;
  921.     info->gluExtensions = NULL;
  922. }
  923.  
  924.  
  925.  
  926. /******************************************************************************
  927.  *
  928.  * PrintEnvironment - print contents of EnvironmentInfo struct
  929.  *
  930.  * Description:
  931.  *  Print the contents of EnvironmentInfo struct. The stream parameter Points
  932.  *  to a FILE structure specifying an open stream to which output will be
  933.  *  written. The title parameter is a pointer to a string which will be output
  934.  *  before any of the EnvironmentInfo data is output, The title string may be
  935.  *  NULL in which case no title string will be written. The leader parameter
  936.  *  is a pointer to a string which will be output before each field in the
  937.  *  EnvironmentInfo struct. The nameWidth parameter is an integer parameter
  938.  *  specifying how pad the name of each field. This can be used to cause the
  939.  *  values to line up in a column. A positive value left justifies, a negative
  940.  *  value right justifies. The suffix parameter is a pointer to a string which
  941.  *  will be output after all of the EnvironmentInfo data is output, The suffix
  942.  *  string may be NULL in which case no suffix string will be written.
  943.  *
  944.  * Returns:
  945.  *  void
  946.  *
  947.  * Side Effects:
  948.  *  file stream output
  949.  *
  950.  * Errors:
  951.  *  None
  952.  *
  953.  * Revision History:
  954.  *  Revision 0: Author: John R. Dennis Date: Wed Sep 14 09:02:57 1994
  955.  *    Initial Release
  956.  *
  957.  *****************************************************************************/
  958.  
  959. void
  960. PrintEnvironment(FILE *stream, EnvironmentInfo *info, char *title,
  961.                  char *leader, int nameWidth, char *suffix)
  962. {
  963.   if (title) fprintf(stream, "%s", title);
  964.  
  965.   fprintf(stream, "%s%*s%d\n", leader, nameWidth,
  966.          "Month", info->month);
  967.   fprintf(stream, "%s%*s%d\n", leader, nameWidth,
  968.          "Day", info->day);
  969.   fprintf(stream, "%s%*s%d\n", leader, nameWidth,
  970.          "Year", info->year);
  971.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  972.          "Host", info->host);
  973.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  974.          "Operating System", info->hostOperatingSystem);
  975.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  976.          "Operating System Version", info->hostOperatingSystemVersion);
  977.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  978.          "Host Vendor", info->hostVendor);
  979.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  980.          "Host Model", info->hostModel);
  981.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  982.          "Host CPU", info->hostCPU);
  983.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  984.          "Host CPU Count", info->hostCPUCount);
  985.   fprintf(stream, "%s%*s%d\n", leader, nameWidth,
  986.          "Host Memory Size (MB)", info->hostMemorySize);
  987.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  988.          "Host Primary Cache Size (KB)", info->hostPrimaryCacheSize);
  989.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  990.          "Host Secondary Cache Size (KB)", info->hostSecondaryCacheSize);
  991.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  992.          "Window System", info->windowSystem);
  993.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  994.           "Driver Version", info->driverVersion);
  995.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  996.          "OpenGL Vendor", info->glVendor);
  997.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  998.          "OpenGL Version", info->glVersion);
  999.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  1000.          "OpenGL Extensions", info->glExtensions);
  1001.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  1002.          "OpenGL Renderer", info->glRenderer);
  1003.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  1004.          "OpenGL Client Vendor", info->glClientVendor);
  1005.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  1006.          "OpenGL Client Version", info->glClientVersion);
  1007.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  1008.          "OpenGL Client Extensions", info->glClientExtensions);
  1009.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  1010.          "GLU Version", info->gluVersion);
  1011.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  1012.          "GLU Extensions", info->gluExtensions);
  1013.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  1014.          "Direct Rendering", info->directRender ? "True" : "False");
  1015.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  1016.          "Double Buffer", info->bufConfig.doubleBuffer ? "True" : "False");
  1017.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  1018.          "Stereo", info->bufConfig.stereo ? "True" : "False");
  1019.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  1020.          "RGBA", info->bufConfig.rgba ? "True" : "False");
  1021.   fprintf(stream, "%s%*s%d\n", leader, nameWidth,
  1022.          "Color Index Size", info->bufConfig.indexSize);
  1023.   fprintf(stream, "%s%*s%d\n", leader, nameWidth,
  1024.          "Red Size", info->bufConfig.redSize);
  1025.   fprintf(stream, "%s%*s%d\n", leader, nameWidth,
  1026.          "Green Size", info->bufConfig.greenSize);
  1027.   fprintf(stream, "%s%*s%d\n", leader, nameWidth,
  1028.          "Blue Size", info->bufConfig.blueSize);
  1029.   fprintf(stream, "%s%*s%d\n", leader, nameWidth,
  1030.          "Alpha Size", info->bufConfig.alphaSize);
  1031.   fprintf(stream, "%s%*s%d\n", leader, nameWidth,
  1032.          "Accum Red Size", info->bufConfig.accumRedSize);
  1033.   fprintf(stream, "%s%*s%d\n", leader, nameWidth,
  1034.          "Accum Green Size", info->bufConfig.accumGreenSize);
  1035.   fprintf(stream, "%s%*s%d\n", leader, nameWidth,
  1036.          "Accum Blue Size", info->bufConfig.accumBlueSize);
  1037.   fprintf(stream, "%s%*s%d\n", leader, nameWidth,
  1038.          "Accum Alpha Size", info->bufConfig.accumAlphaSize);
  1039.   fprintf(stream, "%s%*s%d\n", leader, nameWidth,
  1040.          "Depth Size", info->bufConfig.depthSize);
  1041.   fprintf(stream, "%s%*s%d\n", leader, nameWidth,
  1042.          "Stencil Size", info->bufConfig.stencilSize);
  1043.   fprintf(stream, "%s%*s%d\n", leader, nameWidth,
  1044.          "Auxiliary Buffer Count", info->bufConfig.auxBuffers);
  1045.   fprintf(stream, "%s%*s%d\n", leader, nameWidth,
  1046.          "Frame BufferLevel", info->bufConfig.level);
  1047.   fprintf(stream, "%s%*s%d\n", leader, nameWidth,
  1048.          "Window Width (pixels)", info->windowWidth);
  1049.   fprintf(stream, "%s%*s%d\n", leader, nameWidth,
  1050.          "Window Height (pixels)", info->windowHeight);
  1051.   fprintf(stream, "%s%*s%d\n", leader, nameWidth,
  1052.          "Screen Width (pixels)", info->screenWidth);
  1053.   fprintf(stream, "%s%*s%d\n", leader, nameWidth,
  1054.          "Screen Height (pixels)", info->screenHeight);
  1055.   if (suffix) fprintf(stream, "%s", suffix);
  1056. }
  1057.  
  1058.